<template>
  <grid-content class="label-production">
    <div class="account-settings-info-main">
      <div class="account-settings-info-left">
        <a-menu
          :key="menuKey"
          type="inner"
          :mode="mode"
          :style="{ border: '0', width: isMobile ? '100%' : 'auto' }"
          v-model:selectedKeys="selectedKeys"
        >
          <a-menu-item key="/label-supermarket/production/create-ai-label/second-level-ai">
            <router-link :to="{ name: 'second-level-ai' }">创建AI专题二级标签</router-link>
          </a-menu-item>
          <a-menu-item key="/label-supermarket/production/create-ai-label/three-level-ai">
            <router-link :to="{ name: 'three-level-ai' }">创建AI专题三级标签</router-link>
          </a-menu-item>
        </a-menu>
      </div>
      <div class="account-settings-info-right">
        <!-- <div class="account-settings-info-title">hhh</div> -->
        <router-view></router-view>
      </div>
    </div>
  </grid-content>
</template>

<script lang="ts">
import {
  defineComponent,
  reactive,
  toRefs,
  onMounted,
  watch,
  inject,
  ref,
  computed,
  onActivated,
} from 'vue';
import { GridContent } from '@/components';
import { useRoute } from 'vue-router';

export default defineComponent({
  name: 'labelProduction',
  setup() {
    const route = useRoute();
    const state = reactive<{
      selectedKeys: string[];
    }>({
      selectedKeys: [],
    });

    const menuKey = ref(1);
    onActivated(() => {
      menuKey.value++;
    });

    const updateCurrentSelectMenu = () => {
      const allMatched = route.matched.concat();
      state.selectedKeys = allMatched.map(item => item.path);
    };

    onMounted(() => {
      updateCurrentSelectMenu();

      watch(
        () => route.fullPath,
        () => {
          updateCurrentSelectMenu();
        },
      );
    });
    const isMobile = inject('isMobile', ref(false));
    return {
      menuKey,
      isMobile,
      mode: computed(() => (isMobile.value ? 'horizontal' : 'vertical')),
      ...toRefs(state),
    };
  },
  components: { GridContent },
});
</script>

<style lang="less" scoped>
.label-production {
}
.account-settings-info-main {
  display: flex;
  width: 100%;
  height: 100%;
  overflow: auto;

  &.mobile {
    display: block;

    .account-settings-info-left {
      width: 100%;
      height: 50px;
      overflow-x: auto;
      overflow-y: scroll;
      border-right: unset;
      border-bottom: 1px solid @border-color-split;
    }
    .account-settings-info-right {
      padding: 20px 40px;
    }
  }

  .account-settings-info-left {
    width: 224px;
    border-right: 1px solid @border-color-split;
  }

  .account-settings-info-right {
    flex: 1 1;
    padding: 8px 40px;

    .account-settings-info-title {
      margin-bottom: 12px;
      color: @text-color;
      font-weight: 500;
      font-size: 20px;
      line-height: 28px;
    }
    .account-settings-info-view {
      padding-top: 12px;
    }
  }
}
@media screen and (max-width: 768px) {
  .account-settings-info-main {
    flex-direction: column;
    .account-settings-info-left {
      width: 100%;
      border-right: none;
    }
  }
}
</style>
